package com.atguigu.tingshu.order.mapper;

import com.atguigu.tingshu.model.order.OrderInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface OrderInfoMapper extends BaseMapper<OrderInfo> {

    @Select("SELECT COUNT(*)\n" +
            "FROM order_info oi\n" +
            "LEFT JOIN order_detail od on oi.id = od.order_id\n" +
            "WHERE oi.is_deleted = 0\n" +
            "and od.item_id = #{albumId}\n" +
            "and oi.user_id = #{userId}\n" +
            "and oi.item_type = #{itemType}\n" +
            "and oi.order_status = \"0901\"")
    int checkAlbumAndVipTypeItemPadding(@Param("itemType") String itemType, @Param("userId") Long userId, @Param("albumId") Long albumId);

        @Select("SELECT od.item_id\n" +
            " FROM order_info oi\n" +
            " LEFT JOIN order_detail od on oi.id = od.order_id\n" +
            " WHERE oi.is_deleted = 0\n" +
            " and oi.user_id = #{userId}\n" +
            " and oi.item_type = #{itemType}\n" +
            " and oi.order_status = \"0901\"")
    List<Long> checkTrackTypeItemPadding(@Param("itemType") String itemType, @Param("userId") Long userId);

    int updateOrderStatus(@Param("orderNo") String orderNo);
}
